<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link href="assets/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="css/style.css"/>
    <link rel="stylesheet" href="assets/css/ace.min.css" />
    <link rel="stylesheet" href="assets/css/font-awesome.min.css" />
    <link href="Widget/icheck/icheck.css" rel="stylesheet" type="text/css" />
    <!--[if IE 7]>
    <link rel="stylesheet" href="assets/css/font-awesome-ie7.min.css" />
    <![endif]-->
    <!--[if lte IE 8]>
    <link rel="stylesheet" href="assets/css/ace-ie.min.css" />
    <![endif]-->
    <script src="js/jquery-1.9.1.min.js"></script>
    <script src="assets/js/bootstrap.min.js"></script>
    <script src="assets/js/typeahead-bs2.min.js"></script>

    <!-- page specific plugin scripts -->
    <script src="assets/js/jquery.dataTables.min.js"></script>
    <script src="assets/js/jquery.dataTables.bootstrap.js"></script>
    <script type="text/javascript" src="js/H-ui.js"></script>
    <script type="text/javascript" src="js/H-ui.admin.js"></script>
    <script src="assets/layer/layer.js" type="text/javascript" ></script>
    <script src="assets/laydate/laydate.js" type="text/javascript"></script>
    <script src="assets/dist/echarts.js"></script>
    <script src="js/lrtk.js" type="text/javascript"></script>
    <title>品牌管理</title>
</head>

<body>
<div class="page-content clearfix" >
    <div id="Member_Ratings">
        <div class="d_Confirm_Order_style">
            <div class="search_style">
                <form  action="/showStat" >
                    <ul class="search_content clearfix">
                        <li><label class="l_f">起始日期</label><input class="inline laydate-icon" id="startTime" style=" margin-left:10px;" name="begin" th:value="${begin}" ></li>
                        <li><label class="l_f">截至日期</label><input class="inline laydate-icon" id="endTime" style=" margin-left:10px;" name="end" th:value="${end}"></li>
                        <li style="width:90px;"><button type="submit" class="btn_search" id="ton" ><i class="icon-search"></i>查询</button></li>
                    </ul>
                </form>
            </div>
            <div class="border clearfix">
                <a href="javascript:ovid()" class="btn btn-danger" onclick="Statistics_btn()"><i class="fa fa-bar-chart"></i>&nbsp;图表展示</a>
            </div>
            <div class="table_menu_list"  >
                <table class="table table-striped table-bordered table-hover" id="sample-table" style="width: 100%"  >
                    <thead>
                        <tr>
                            <th width="100px">编号</th>
                            <th width="100px">商品类型</th>
                            <th width="80px">销售额</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr  th:each="list:${lists}">
                            <td th:text="${listStat.index+1}"></td>
                            <td th:text="${list['name']}"></td>
                            <td th:text="${list['value']}"></td>
                        </tr>
                        </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<div id="Statistics" style="display:none">
    <div id="main" style="height:400px; overflow:hidden; width:1000px; overflow:auto" class="side_list"></div>
</div>
</body>
<script>
    jQuery(function($) {
        var oTable1 = $('#sample-table').dataTable( {
            //"aaSorting": [ 1, "desc" ],//默认第几个排序
            "bStateSave": true,//状态保存
            "searching": false,
            "lengthMenu": [ 10, 50, 75, 100],
            "columnDefs": [
                {targets: 9, orderable: false, width: "10%"},
            ],
            "aoColumnDefs": [
                //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
                {"orderable":false,"aTargets":[0]}// 制定列不参与排序
            ] } );


        $('table th input:checkbox').on('click' , function(){
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                .each(function(){
                    this.checked = that.checked;
                    $(this).closest('tr').toggleClass('selected');
                });

        });


        $('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
        function tooltip_placement(context, source) {
            var $source = $(source);
            var $parent = $source.closest('table')
            var off1 = $parent.offset();
            var w1 = $parent.width();

            var off2 = $source.offset();
            var w2 = $source.width();

            if( parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2) ) return 'right';
            return 'left';
        }
    });


    // //初始化宽度、高度
    $(".chart_style").height($(window).height()-150);
    $(".table_menu_list").height($(window).height()-150);
    $(".table_menu_list ").width($(window).width()-440);
    // //当文档窗口发生改变时 触发
    // $(window).resize(function(){
    //     $(".chart_style").height($(window).height()-215);
    //     $(".table_menu_list").height($(window).height()-215);
    //     $(".table_menu_list").width($(window).width()-440);
    // });
    //图层隐藏限时参数
    $(function() {
        $("#category").fix({
            float : 'left',
            //minStatue : true,
            skin : 'green',
            durationTime :false,
            stylewidth:'400',
            spacingw:30,//设置隐藏时的距离
            spacingh:440,//设置显示时间距
        });
    });


</script>
<script type="text/javascript" th:inline="javascript">
        // function  func() {
        //     var begin = $("#startTime").val();
        //     var end = $("#endTime").val();
        //     alert(begin);
        //     alert(end);
        //     var url = "/statRefresh?begin="+begin+"&end="+end;
        //     $.ajax({
        //         url: url,
        //         success: function (data) {
        //             $("#sample-table").html(data);
        //         }
        //     })
        // }
    function Statistics_btn(){
        layer.open({
            type: 1,
            title: '当月销售统计',
            // maxmin: true,
            // shadeClose:false,
            area : ['1000px' ,'500px'],
            content:$('#Statistics'),
            btn:['确定','取消'],
        })
    }

    $(function(){

        var arr=[];
        var  use = [[${lists}]];
        for(var i=0;i<use.length;i++){
            arr[i]=use[i].name
        }
    require.config({
        paths: {
            echarts: './assets/dist'
        }
    });
    require(
        [
            'echarts',
            'echarts/chart/pie',   // 按需加载所需图表，如需动态类型切换功能，别忘了同时加载相应图表
            'echarts/chart/funnel'
        ],
        function (ec) {
            var myChart = ec.init(document.getElementById('main'));

            option = {
                title : {
                    text: '销售统计图',
                    subtext: '',
                    x:'center'
                },
                tooltip : {
                    trigger: 'item',
                    formatter: "{a} <br/>{b} : {c} ({d}%)"
                },
                legend: {
                    orient : 'vertical',
                    x : 'left',
                    data: arr
                },
                toolbox: {
                    show : false,
                    feature : {
                        mark : {show: false},
                        dataView : {show: false, readOnly: false},
                        magicType : {
                            show: true,
                            type: ['pie', 'funnel'],
                            option: {
                                funnel: {
                                    x: '25%',
                                    width: '50%',
                                    funnelAlign: 'left',
                                    max: 545
                                }
                            }
                        },
                        restore : {show: true},
                        saveAsImage : {show: true}
                    }
                },
                calculable : true,
                series : [
                    {
                        name:'品牌数量',
                        type:'pie',
                        radius : '55%',
                        center: ['50%', '60%'],
                        data: [[${lists}]]

                    }
                ]
            };

            myChart.setOption(option);
        }
    );
    });
</script>
<script type="text/javascript">

    var start ={
        elem: '#startTime'
        ,format: 'YYYY-MM-DD'
        ,choose:function(date){
            end.min=date;
        }
    }
    var end= {
        elem: '#endTime'
        ,format: 'YYYY-MM-DD'
        ,choose:function(date){
            start.max=date;
        }
    }
    laydate(start);
    laydate(end);

</script>

</html>